home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / cug233 / make.doc < prev    next >
Text File  |  1987-06-30  |  4KB  |  101 lines

  1.     MAKE is originally one of UNIX utilities. MAKE is used to simplify
  2. the compilation and linkage process of high-level language (C, PASCAL,
  3. Fortran ..etc) programs consisting more than one source files. This MAKE is
  4. directly imported from the article by Allen Holub in Dr. Dobb's Journal, August
  5. 1985 issue and compiled under Microsoft C ver.4.0 and Lattice C ver.3.
  6.  
  7.     MAKE uses a makefile called MKFILE that describes the target files,
  8. their relationship(dependency)  and actions(command line) as an example shown
  9. below.
  10.  
  11. #
  12. # Make green using Microsoft C compiler
  13. #
  14.  
  15. green.exe:    yellow.obj blue.obj
  16.         link yellow + blue /CO;
  17.  
  18. yellow.obj:    yellow.c color.h
  19.         msc yellow /I c:\bin /Zi;
  20.  
  21. blue.obj:    blue.c color.h
  22.         msc blue /I c:\bin /Zi;
  23.  
  24. color.h:
  25.  
  26. blue.c:
  27.  
  28. yellow.c:
  29.  
  30. # End of Make
  31.  
  32.     MAKE reads MKFILE and compares the last modification date of the target
  33. file or files  with the modification dates of files on which these target files
  34. depend. If the target file is older than the dependant files, MAKE then does
  35. recompiling or relinking.
  36.     In the example above, if you change something in yellow.c, MAKE
  37. discovers the change, recompiles yellow.c and generates yellow.obj. Moreover,
  38. because green.exe depends on yellow.obj, relinking is performed. If color.h is
  39. changed, both yellow.c and blue.c are recompiled and relinked.
  40.     Because MAKE exactly defines the relationship between modules as
  41. described above, you can save the time of reconfiguring and recompiling
  42. everything.
  43.  
  44. To use MAKE, you first need to create MKFILE with your text editor. The rule
  45. applied to MKFILE is :
  46.  
  47. (1)    A # sign in column 1 designates a comment line. The # must be in the
  48.     leftmost column.
  49.  
  50. (2)    The dependency line comes first. It uses the format;
  51.  
  52.     "targetfile:dependentfiles"
  53.  
  54.     Ex.
  55.     green.exe:     yellow.obj blue.obj
  56.  
  57.     The colon is required (an error message is printed if it's not there)
  58.     and no space is allowed between the filename and the colon.
  59.     The dependencies are delimited from one another with white space (any
  60.     combination of tabs or blanks). The dependencies must all be listed on
  61.     a single line: however, any line terminated with a back-slash(\) will
  62.     be continued to the next line.
  63.  
  64.     Ex.
  65.         green.exe:    yellow.obj\
  66.               blue.obj
  67.  
  68.     No white space is allowed between the end of the line and the
  69.     back-slash.
  70.  
  71. (3)    All files listed as dependencies must be used as targets somewhere in
  72.     MKFILE. A null tareget(no dependencies) is permitted.
  73.  
  74. (4)    All lines following the dependency line, up to a blank line, are the
  75.     actions executed to make the target. The blank line is required to
  76.     terminate the block of actions. Any number of blank lines are permitted
  77.     as a terminator, but any nonblank line following a blank line is assumed
  78.     to be a new dependency line.
  79.  
  80. (5)    Targets having no dependenies will always be made.
  81.     Ex.
  82.     listing:
  83.         print color.h yellow.c blue.c
  84.  
  85.     will always execute the print command.
  86.  
  87. (6)    For the sake of comparison, all nonexistent files are considered to
  88.     exist and to be very old, so a nonexistent file listed to the left of
  89.     a colon will always be made. The dates and times associated with a
  90.     target are updated as soon as the target is made.
  91.  
  92. After you have your customized MKFILE, you can run MAKE. In the command line,
  93. you just type MAKE.
  94.     If you have a target filename after MAKE, MAKE starts doing make from
  95. there in MKFILE. For example, if you type MAKE yellow.obj, yellow.obj may be
  96. updated, however green.exe will never be updated.
  97.  
  98.  
  99. /* Warning */
  100.  
  101. MAKE compiler under Lattice C will require MS-DOS ver 3.0 or above.